package 力扣._206_反转链表;
import 力扣.公用数据结构.ListNode;

public class Solution {


    //头插法,但这个不带头结点
    public ListNode reverseList(ListNode head) {
        if (head == null)
            return null;
        ListNode t = new ListNode(0); //头结点
        t.next = head;
        head = t;
        ListNode p = head.next;

        head.next = null;
        while (p != null) {
            t = p;
            p = p.next;
            t.next = head.next;
            head.next = t;
        }
        return head.next;
    }

    public static void main(String[] args) {

    }
}